import type {
  ProjectAddDTOType,
  ProjectUpdateDTOType,
  ProjectSearchDTOType,
} from '@/resources/interface/project/ProjectTypes.ts'
import type { ResultTypes } from '@/resources/interface/ResultTypes'
import { HttpResultUtil } from '@/apis/utils/HttpResultUtil'

export class ProjectApi {
  private static addUrl: string = '/project/add'
  private static updateUrl: string = '/project/update'
  private static searchUrl: string = '/project/search'
  private static deleteUrl: string = '/project/delete'
  private static studentProjectUrl: string = '/project/student/project'

  static list(): Promise<ResultTypes> {
    return HttpResultUtil.awaitGet(this.studentProjectUrl, null, false)
  }

  static add(data: ProjectAddDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.addUrl, data, true)
  }

  static update(data: ProjectUpdateDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.updateUrl, data, true)
  }

  static search(data: ProjectSearchDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.searchUrl, data, false)
  }

  static delete(idList: Array<number>): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.deleteUrl, idList, true)
  }
}
